package club.emergency.wechat.interceptor;

import club.emergency.wechat.interceptor.impl.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Create with IntelliJ IDEA
 * Project Name: wechat
 * Package Name: club.emergency.wechat.interceptor
 * Date: 2018/12/4
 *
 * @author: 快乐的小菌菌
 * Description:
 */
@Configuration
public class InterceptorConfiguration implements WebMvcConfigurer {

    private LoginInterceptor loginInterceptor;

    public InterceptorConfiguration(LoginInterceptor loginInterceptor) {
        this.loginInterceptor = loginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns("/manager-search/login")
                .excludePathPatterns("/staff-search/signature")
                .excludePathPatterns("/staff-operate/save")
                .excludePathPatterns("/wechat-basic/getOpenidByCode")
                .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
    }
}
